import equals from 'deep-equal';
/**
 * 获取十六进制的颜色代码.例如  "#6E36B4" , For HTML ,
 * @return String
 */
const colorList = [];
export const getRandColorCode = () => {
  let r,
    g,
    b;
  r = Math.round(Math.random() * 256).toString(16).toUpperCase();
  g = Math.round(Math.random() * 256).toString(16).toUpperCase();
  b = Math.round(Math.random() * 256).toString(16).toUpperCase();

  r = r.length == 1 ? `0${r}` : r;
  g = g.length == 1 ? `0${g}` : g;
  b = b.length == 1 ? `0${b}` : b;


  if (colorList.indexOf(`#${r}${g}${b}`) > -1 || equals((r + g + b), 'FFFFFF') || equals((r + g + b), '000000')) {
    return getRandColorCode();
  }
  colorList.push(`#${r}${g}${b}`);
  return `#${r}${g}${b}`;
};

